Sort Mode

BibDB can be told to manually or automatically support sorted database files. The sort criterion is the following:

Additionally, one can choose between two collation sequences, ASCII and mixed case. Using mixed case, ``abc" will come after ``Abc" but before ``Acd". The user can define the sort criterion to be any combination of the three, in any order. Sorting by name will always be defined, however, and put as the last criterion by default.

BibDB can be put into one of three sort modes: off, on and auto. In off mode, sorting is performed only when the ``Sorted" option is chosen in the ``Add" or ``Imp." menus. In on mode, entries will always be placed in their proper place in the file according to the configuration file defined sort order. BibDB will then complain and refuse to add, import or edit the file if it finds it is unsorted. In auto mode, BibDB will automatically determine if the file is sorted or unsorted, and will put itself into on or off mode accordingly. As for new files, BibDB will regard any file with less than 2 entries as sorted in on mode, and unsorted in off or auto mode. Note that entry adding and (sometimes) editing will be significantly slower in sort mode than in unsorted mode.

In addition to reading the various sort options from the configuration file, BibDB will also read sort information from database files, if available. In order to specify the sort options for a file, you should include a `` \sort{" configuration environment at the beginning of the file. More precisely, the beginning of the sort environment (the \sort{ line) should be in the first five lines of the file. The format of this sort configuration environment is identical to the format of the sort environment in the configuration file, except that the ``AddToNewFiles" parameter is ignored. If BibDB finds such an environment in a file, it will load it and use these parameters instead of the current ones. Using this feature one can keep different files sorted in different orders, and also keep some files unsorted, letting BibDB keep track of the sorting of each file automatically.

BibDB keeps track of two independent sets of sort parameters, the default mode and the current mode. Both of these modes can be independently edited using the sort options screen. BibDB will copy the default mode into the current mode whenever you switch to a database file which does not have a sort environment. Additionally, if sorting is off in the default mode, it will stay off until switched back on manually.

BibDB can be told to automatically insert sort environments into new files whenever it is appropriate. This feature is controlled by the ``AddToNewFiles" sort parameter, which is accessible in the configuration file and in the sort options screen. If ``AddToNewFiles" is set to ``all", the current sort mode will be added to all new files, while setting it to ``sorted" will cause the current sort mode to be written to new files only if sorting is switched on. Finally, the current or default sort parameters can be written onto the current database file (replacing any existing sort environment) using the ``Save" command of the sort options screen.